<style>
.pure_form_extra label, .pure_form_extra input { font-size: 12px !important; }
.pure_form_extra label * { font-size: 12px !important; }
.pure_form_extra .mandatory { color: #ff0000; padding-left: 5px; }
.pure_form_extra { width: 100%; }
</style>

<?php 
$active = Utils::get_param('at', 0);
$user = json_decode($_SESSION['admin_user']);
?>
<div class="pure-form" style="margin-bottom: 5px;">
  <h3 id="student_title" style="display: inline-block; min-width: 200px;"></h3>
  <input id="keywords" type="text" style="width: 160px; margin-left: 15px;" placeholder="{Search Another}" onkeypress="if(event.which == 13) search(1, 'id_number', 'ASC');">
</div>
<div id="tabs">
  <ul>
    <li onclick="Url.insert_param('at', 0);"><a href="#personal">Personal</a></li>
    <li class="expg" onclick="Url.insert_param('at', 1);"><a href="#enrollments">Enrollments</a></li>
    <li class="expg" onclick="Url.insert_param('at', 2);"><a href="#academic">Academic</a></li>
    <li class="expg" onclick="Url.insert_param('at', 3);"><a href="#attendance">Attendance</a></li>
    <li class="expg" onclick="Url.insert_param('at', 4);"><a href="#courses">Courses</a></li>
    <?php if ($user->role == UT_ADMIN || $user->role == UT_FINANCE) { ?>
    <li class="expg" onclick="Url.insert_param('at', 5);"><a href="#finance">Invoices & Payments</a></li>
    <?php } ?>
  </ul>
  <div id="personal"><?php include "inc.personal.php"; ?></div>
  <div id="enrollments"><?php include "inc.enrollments.php"; ?></div>
  <div id="academic"><?php include "inc.academic.php"; ?></div>
  <div id="attendance"><?php include "inc.attendance.php"; ?></div>
  <div id="courses"><?php include "inc.courses.php"; ?></div>
  <?php if ($user->role == UT_ADMIN || $user->role == UT_FINANCE) { ?>
  <div id="finance"><?php include "inc.finance.php"; ?></div>
  <?php } ?>
</div>

<?php include '../include/colg/inc.enrl.js.php'; ?>

<script>
  /*<![CDATA[*/
  var __active = '<?php echo $active; ?>';
  var __dir = '<?php echo PLGN_DIR . basename(dirname(__FILE__)); ?>';
  var __requrl = '<?php echo Utils::get_requrl($app_data); ?>';
  var __file = '<?php echo addslashes($app_data->param_file); ?>';
  var __redmd = '<?php echo addslashes($app_data->sys->redmd); ?>';
  var __sys = '<?php echo addslashes($app_data->sys->php_name); ?>';
  var __id = '<?php echo $app_data->param_id; ?>';
  var __date = '<?php echo $date; ?>';
  var __user = JSON.parse('<?php echo addslashes(json_encode($user)); ?>');

  $(function() {
    $('#tabs').tabs({
      active: __active
    });
    $('#keywords').autocomplete({
      source: __requrl.replace('index_student', 'index') + 'autocomplete',
      minLength: 2,
      select: function(event, ui) {
        $('#keywords').val(ui.item.value);
        search(1, 'id_number', 'ASC');
      }
    });
    render();
  });

  function render() {
    if (__data[0].id != 0) {
      $('.expg').show();
    } else {
      $('.expg').hide();
    }
    Utils.leftbar(
      __objs,
      __data[0].id,
      'Students',
      'title__',
      function(page) {
        Url.redirect(__redmd, __sys + '.php?i=' + __id + '&__file=' + __file + '&id=' + __data[0].id + '&pg=' + page);
      }
    );
    render_data();
    render_enrls();
    render_academic();
    render_atdn();
    render_courses();
    if (__user.role == 'Admin' || __user.role == 'Finance') {
      render_finance();
    }
  };
  
  function get_obj(id) {
    Url.redirect(__redmd, __sys + '.php?i=' + __id + '&__file=' + __file + '&id=' + id + '&at=' + Url.get_param('at', 0) + '&pg=' + Url.get_param('pg', 1));
    return false;
  };

  function search(pg, o, q) {
    var req = {
      term: $('#keywords').val(),
      pg: pg,
      q: q,
      o: o,
    }
    Ajax.request(
      __requrl.replace('index_student', 'index') + 'search',
      'req=' + Utils.encodeURI(JSON.stringify(req)),
      function(rslt) {
        if (rslt.d.length == 1) {
          Url.redirect(__redmd, __sys + '.php?i=' + __id + '&__file=' + __file + '&id=' + rslt.d[0].id + '&at=' + Url.get_param('at', 0));
        }
      },
      null
    );
    return false;
  };
  /*]]>*/
</script>